package ZuoYe02_FangFa_0429;

import ZuoYe01_LeiyuDuiXiang_0428.QiChe;

//1:Car
//汽车有品牌、价格、重量、当前油量等属性，
//有行驶、刹车、鸣笛等方法。
//行驶中，油量会一直减少。当油量为0，汽车无法行驶。
//用oo的思想模拟实现这个过程。
public class Car {
	String name;
	String brand;
	double price;
	double weight;
	double oil;

	public void shuXing() {
		System.out.println(name + "的品牌是:" + brand + "，价格是:" + price + "万，车重是:" + weight + "KG，当前油量是:" + oil + "L");
	}

	public void xingShi() {
		System.out.println(name + "行驶中！油量：" + oil + "；油量-5。");

	}

	public void shaChe() {
		System.out.println(name + "刹车！");

	}

	public void mingDi() {
		System.out.println(name + "鸣笛！");
	}

	public static void main(String[] args) {
		Car car = new Car();
		car.name = "二手奥拓";
		car.brand = "奥拓";
		car.price = 8.8;
		car.weight = 1500;
		car.oil = 50;

		car.shuXing();

		for (; car.oil > 0; car.oil -= 5) {// 百度到的计时方法
			try {
				Thread.sleep(2 * 1000); // 设置暂停的时间 2 秒
				car.xingShi();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		System.out.println(car.name + "油量：" + car.oil + car.name + "没油了……");

		car.mingDi();
		car.shaChe();
	}

}
